package com.len.controller;

import com.alibaba.fastjson.JSON;
import com.github.pagehelper.Page;
import com.len.entity.PayEntity;
import com.len.exception.MyException;
import com.len.service.PayService;
import com.len.util.JsonUtil;
import com.len.util.ReType;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

@Controller
@RequestMapping(value = "/shop/pay")
@Slf4j
@RequiresPermissions("pay:showList")
public class PayController {

    @Resource
    private PayService payService;

    @GetMapping(value = "showList")
    public String showList() {
        return "/shop/pay/payList";
    }

    @GetMapping(value = "getList")
    @ResponseBody
    public String getList(PayEntity payEntity, String page, String limit) {

        Page<PayEntity> tPage = new Page<>(Integer.parseInt(page), Integer.parseInt(limit));
        tPage = payService.getList(payEntity,tPage);
        ReType reType = new ReType(tPage.getTotal(), tPage.getResult());
        return JSON.toJSONString(reType);
    }

}
